package com.crm.controller;

import com.crm.commons.domain.ResponseData;
import com.crm.service.ICrmClueActivityRelationService;
import com.crm.vo.ClueActivityRelation;
import com.crm.vo.ClueRemark;
import com.crm.vo.SysActivity;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author junxian,dou
 * @since 2024-11-25
 */
@RestController
@RequestMapping("/crmClueActivityRelation")
public class CrmClueActivityRelationController {

    @Resource
    private ICrmClueActivityRelationService crmClueActivityRelationService;

    @ApiOperation("添加线索和活动的关系")
    @PostMapping("/addClueActivityRelation")
    public ResponseData addClueActivityRelation(@RequestBody ClueActivityRelation clueActivityRelation){
        crmClueActivityRelationService.addClueActivityRelation(clueActivityRelation);
        return ResponseData.success();
    }

    @ApiOperation("移除线索和活动的关系")
    @GetMapping("/deleteClueActivityRelation/{id}")
    public ResponseData deleteClueActivityRelation(@PathVariable String id){
        crmClueActivityRelationService.deleteClueActivityRelationWithId(id);
        return ResponseData.success();
    }


    @ApiOperation("移除线索和活动的关系")
    @GetMapping("/clueActivityRelation/{id}")
    public ResponseData clueActivityRelation(@PathVariable String id){
        List<SysActivity> crmActivities = crmClueActivityRelationService.getRelationActivityWithClueId(id);
        return ResponseData.success(crmActivities);
    }


    @GetMapping("/queryActivityForConvertByNameClueId/{clueId}")
    public ResponseData queryActivityForConvertByNameClueId(@PathVariable String clueId,@RequestParam(required = false) String name){
        //调用service层方法，查询市场活动
        List<SysActivity> activityList=crmClueActivityRelationService.queryActivityForConvertByNameClueId(clueId,name);
        //根据查询结果，返回响应信息
        return ResponseData.success(activityList);
    }

}
